package org.fas.utils
{
	import flash.utils.setTimeout;
	
	public class FuObject
	{
		static public function waitAct(_ob:Object,_func:Function):void{
			if(_ob!=null){
				_func();
				//flash.utils.clearTimeout(waitTimerId);
			}else{
				flash.utils.setTimeout(waitAct,10,_ob,_func);
			}
		}
		static public function setTo(_target:Object,_params:Array,_values:Array):void{
			for(var i:int=0;i<_params.length;i++){
				_target[_params[i]] = _values[i];
			}
		}
		static public function echo(_ob:Object,_isTarce:Boolean=false):String{
			var _r:String="---object:---\n";
			for(var p:String in _ob){
				_r += (p+":")
				_r += _ob[p];
				_r += "\n";
			}
			_r+="---end---"
			if(_isTarce){
				trace(_r);
			}
			return _r;
		}
		public static function copyObject(_ob:Object,_args:Array=null):Object{
			var  _v:Object = new Object;
			copyObjectTo(_ob,_v,_args);
			return _v;
		}
		public static function copyObjectTo(_obSource:Object,_obAim:Object,_args:Array=null):void{
			if(_args==null){
				for(var _p:String in _obSource){
					_obAim[_p] = _obSource[_p];
				}
			}else{
				for(var i:int=0;i<_args.length;i++){
					_obAim[_args[i]] = _obSource[_args[i]];
				}
			}
		}
		public static function compareObject(_ob1:Object,_ob2:Object,_args:Array=null):int{
			var _differentSum:int = 0;
			if(_args==null){
				for(var _p:String in _ob2){
					if(_ob1[_p] != _ob2[_p]){
						_differentSum++;
					}
				}
			}else{
				for(var i:int=0;i<_args.length;i++){
					if(_ob1[_args[i]] != _ob2[_args[i]]){
						_differentSum++;
					}
				}
			}
			return _differentSum;
		}
	}
}